#include "SolParameter.h"
using SG::DataStructure::FEM::ModeCombType;
using SG::DataStructure::FEM::SolParameter;

bool SolParameter::ExecuteRespSpectrumAnalysis () const
{
    bool needRespSpecrm {false};
    static const std::string SCRSPEC_STR = "SCRSPEC";
    if (m_parameter.Has(SCRSPEC_STR))
    {
        int scrpesc = std::stoi (m_parameter[SCRSPEC_STR].GetString());
        needRespSpecrm = (0 == scrpesc);
    }

    return needRespSpecrm;
}

ModeCombType SolParameter::GetModeCombMethod () const
{
    ModeCombType type {COMB_UnKown};

    // "Param, CQC, cqc" 默认值为 -1
    int cqc = -1;
    static const std::string CQC_STR = "CQC";
    if (m_parameter.Has(CQC_STR))
    {
        cqc = std::stoi (m_parameter[CQC_STR].GetString());
    }

    // cqc 为 1或者2， 使用 “CQC”方法；否则（cqc = -1 或者 0）使用传动方法
    if (cqc >= 1)
    {
        type = ModeCombType::COMB_CQC;
    }
    else
    {
        // setting default 传统方法默认值为 COMB_ABS
        type = ModeCombType::COMB_ABS;
        static const std::string OPTION_STR = "OPTION";
        if (m_parameter.Has(OPTION_STR))
        {
            auto option = m_parameter[OPTION_STR].GetString();
            if ("ABS" == option )
            {
                type = ModeCombType::COMB_ABS;
            }
            else if ("SRSS" == option)
            {
                type = ModeCombType::COMB_SRSS;
            }
            else if ("NRL" == option)
            {
                type = ModeCombType::COMB_NRL;
            }
            else
            {
                // Illegal "option" value
                type = ModeCombType::COMB_UnKown;
            }
        }
    }

    return type;
}